package net.wangds.auth.module;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.LinkedList;

public class Anonymous implements UserDetails {

    private String username;

    private String passwrod;

    private Collection<GrantedAuthority> authorities = new LinkedList<>();

    public Anonymous(){
        this.username = "ANONYMOUS";
        this.passwrod = "";
        authorities.add(new SimpleGrantedAuthority("ROLE_ANONYMOUS"));
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return passwrod;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    @Override
    public String toString(){
        return this.username;
    }
}
